package com.symone.webcms.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.symone.webcms.mapper.ModuleFieldMapper;
import com.symone.webcms.model.ModuleField;
import com.symone.webcms.service.ModuleFieldService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *　　
 *   @description : ModuleField 服务实现类
 *   ---------------------------------
 * 	 @author Archer Chu
 *   @since 2019-01-09
 */
@Service
public class ModuleFieldServiceImpl extends ServiceImpl<ModuleFieldMapper, ModuleField> implements ModuleFieldService {

    @Override
    public Page<ModuleField> findPage(Page<ModuleField> page, Wrapper<ModuleField> moduleField) {
        List<ModuleField> result = baseMapper.selectPage(page,moduleField);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<ModuleField> findAll() {
        Wrapper<ModuleField> ew = new EntityWrapper<ModuleField>();
        ew.where("deleted=0");
        return baseMapper.selectList(ew);
    }

    @Override
    public int delete(long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public boolean deleteFlagById(long id) {
        return baseMapper.deleteFlagById(id);
    }

    @Override
    public int clear() {
        return baseMapper.delete(new EntityWrapper<ModuleField>().eq("deleted" ,1));
    }

    @Override
    public List<ModuleField> findModuleFieldList() {
        return baseMapper.findModuleFieldList();
    }

    @Override
    public Page<ModuleField> findModuleFieldList(Page<ModuleField> page,String module) {
        List<ModuleField> result = baseMapper.findModuleFieldList(page,module);
        page.setRecords(result);
        return page;
    }
}
